package base.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;

import com.ibm.icu.text.SimpleDateFormat;

public class QqPayLog {

//	记录日志
	public static void jilu(String name ,String data) throws IOException{
		  File file =new File("C://qqPayLog/"+name);
		  if(!file.exists()){
		   file.createNewFile();
		  }
		  BufferedWriter w = new BufferedWriter(new FileWriter(file,true));
		  SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		  String dateString = formatter.format(new Date());
		  w.append(dateString);
		  w.newLine();
		  w.append(data);
		  w.newLine();
		  w.close();
	}
	public static String qqCanShu(SortedMap<Object, Object> parameters){
		Set es = parameters.entrySet();
        Iterator it = es.iterator();
        StringBuffer sb = new StringBuffer();
        while(it.hasNext()) {
            Map.Entry entry = (Map.Entry)it.next();
            String k = (String)entry.getKey();
            Object v = entry.getValue();
            if(null != v && !"".equals(v) ) {
                sb.append(k + "=" + v + "&");
            }
        }
        String s=sb.substring(0, sb.length()-1);
        System.out.println(s);
		
		return s;
	}
}
